<!-- parcelados/confirm -->
<h1>Despesa parcelada</h1>

<%= flash_alerts %>

<div class="row-fluid">
	<div class="span12">
		<fieldset>
			<%= show_model @parcelado, :only => ["data", "valor", "parcelas", "observacao"] %>
		</fieldset>
	</div>
</div>

<div class="row-fluid">
	<div class="span12">

		<%= bootstrap_alert do %>
			<p>Confira os dados dos parcelamentos</p>
		<% end %>

		<%= form_for @parcelado do |f| %>
			<%= f.hidden_field :data %>
			<%= f.hidden_field :valor %>
			<%= f.hidden_field :parcelas %>
			<%= f.hidden_field :observacao %>

			<table class="table table-striped">
				<thead>
					<tr>
						<th colspan="3">Parcelas</th>
					</tr>
					<tr>
						<th class="span2">Parcela</th>
						<th class="span5">Data</th>
						<th class="span5">Valor</th>
					</tr>
				</thead>
			
				<tbody>
					<% @parcelas.each do |p| %>
						<%= f.fields_for :parcelamento, p do |pf| %>
							<tr>
								<td class="text-center">
									<span><%= p.ordem %></span>
									<%= pf.hidden_field :ordem %>
								</td>
								<td class="text-center">
									<%= pf.text_field :data,
										:value => I18n.localize(p.data),
										:class => "datepicker text-center" %>
								</td>
								
								<td class="text-center">
									<%= pf.text_field :valor,
										:value => p.valor,
										:class => "valor text-right" %>
								</td>
							</tr>
						<% end %>
					<% end %>
				</tbody>	

			</table>

			<div>
				<%= f.submit "Enviar", :class => "btn btn-primary" %>
				<%= link_to "Voltar", (@parcelado.new_record?) ?
																new_parcelado_path :
																	edit_parcelado_path(@parcelado) %>
			</div>
		<% end %>
	</div>
</div>

